using System;
using System.Collections.Generic;
using System.Text;

namespace DDInfo32 {
    public struct GoodNumber : IComparable {
        public long valve;

        public GoodNumber(long valve) { this.valve = valve; }

        public static implicit operator long(GoodNumber org) {
            return org.valve;
        }

        public int CompareTo(object obj) {
            GoodNumber xx = (GoodNumber)this;
            GoodNumber yy = (GoodNumber)obj;
            return xx.valve.CompareTo(yy.valve);
        }

        public override string ToString() {
            if (valve < 0) {
                return "-" + (new GoodNumber(-valve).ToString());
            }
            else if (valve < 1024L) {
                return string.Format("{0} B", valve);
            }
            else if (valve < 1024L * 1000) {
                return string.Format("{0:0.00} KB", valve / 1024.0);
            }
            else if (valve < 1024L * 1024 * 1000) {
                return string.Format("{0:0.00} MB", valve / 1024.0 / 1024.0);
            }
            else if (valve < 1024L * 1024 * 1024 * 1000) {
                return string.Format("{0:0.00} GB", valve / 1024.0 / 1024.0 / 1024.0);
            }
            else {
                return string.Format("{0:0.00} TB", valve / 1024.0 / 1024.0 / 1024.0 / 1024.0);
            }
        }
    }
}
